/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * chinh.java
 *
 * Created on 19-05-2011, 01:19:01
 */
package Project.GUI;

import Project.DBHelper;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.sql.Connection;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JDesktopPane;
import javax.swing.JLabel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import util.CloseableTabComponent;

/**
 *
 * @author phamcuong
 */
public class MainFrame extends javax.swing.JFrame {

    JDesktopPane desktop;

    /** Creates new form chinh */
    public MainFrame() throws UnsupportedLookAndFeelException {
        try {

            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        } catch (InstantiationException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        } catch (UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
        }


        initComponents();

        Dimension screeSize = Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screeSize.width - 1000) / 2, (screeSize.height - 700) / 2, 1000, 700);
//        ImageIcon imageBack = new ImageIcon("D:\\06.JPG");
//
//        JLabel background = new JLabel(imageBack);
//
//        background.setBounds(0, 0, imageBack.getIconWidth(), imageBack.getIconHeight());
//
//         getLayeredPane().add(background, new Integer(Integer.MIN_VALUE));
//
//        jPanel1.setOpaque(false);
//
//        setContentPane(jPanel1);
        DBHelper help = new DBHelper();
        desktop = new JDesktopPane();
        setContentPane(desktop);
        setLocationRelativeTo(this);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar1 = new javax.swing.JMenuBar();
        JSystem = new javax.swing.JMenu();
        Password = new javax.swing.JMenuItem();
        Logout = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        Exit = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        Patient = new javax.swing.JMenuItem();
        Doctor = new javax.swing.JMenuItem();
        Medicine = new javax.swing.JMenuItem();
        Room = new javax.swing.JMenuItem();
        Factualy = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        patient = new javax.swing.JMenuItem();
        doctor = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        addmission = new javax.swing.JMenuItem();
        dischage = new javax.swing.JMenuItem();
        prescription = new javax.swing.JMenuItem();
        healthChechup = new javax.swing.JMenuItem();
        viewCaseHistory = new javax.swing.JMenuItem();
        chageTreatment = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        JSystem.setText("System");
        JSystem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JSystemActionPerformed(evt);
            }
        });

        Password.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/pencil_48.png"))); // NOI18N
        Password.setText("Change Password");
        Password.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PasswordActionPerformed(evt);
            }
        });
        JSystem.add(Password);

        Logout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/logout.png"))); // NOI18N
        Logout.setText("Logout");
        Logout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LogoutActionPerformed(evt);
            }
        });
        JSystem.add(Logout);
        JSystem.add(jSeparator1);

        Exit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/exit.gif"))); // NOI18N
        Exit.setText("Exit");
        Exit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ExitActionPerformed(evt);
            }
        });
        JSystem.add(Exit);

        jMenuBar1.add(JSystem);

        jMenu2.setText("List Management");
        jMenu2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu2ActionPerformed(evt);
            }
        });

        Patient.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Users.png"))); // NOI18N
        Patient.setText("Patient");
        Patient.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PatientActionPerformed(evt);
            }
        });
        jMenu2.add(Patient);

        Doctor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/UserManager.png"))); // NOI18N
        Doctor.setText("Doctor");
        Doctor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DoctorActionPerformed(evt);
            }
        });
        jMenu2.add(Doctor);

        Medicine.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/images0.jpeg"))); // NOI18N
        Medicine.setText("Medicine");
        Medicine.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MedicineActionPerformed(evt);
            }
        });
        jMenu2.add(Medicine);

        Room.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/rr.jpeg"))); // NOI18N
        Room.setText("Room");
        Room.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RoomActionPerformed(evt);
            }
        });
        jMenu2.add(Room);

        Factualy.setText("Factualy");
        Factualy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FactualyActionPerformed(evt);
            }
        });
        jMenu2.add(Factualy);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Search");

        patient.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/Users.png"))); // NOI18N
        patient.setText("Patient");
        patient.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                patientActionPerformed(evt);
            }
        });
        jMenu3.add(patient);

        doctor.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/UserManager.png"))); // NOI18N
        doctor.setText("Doctor");
        doctor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                doctorActionPerformed(evt);
            }
        });
        jMenu3.add(doctor);

        jMenuBar1.add(jMenu3);

        jMenu4.setText("Business");

        addmission.setText("Addmission");
        addmission.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addmissionActionPerformed(evt);
            }
        });
        jMenu4.add(addmission);

        dischage.setText("Dischage");
        dischage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dischageActionPerformed(evt);
            }
        });
        jMenu4.add(dischage);

        prescription.setText("Prescription");
        prescription.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                prescriptionActionPerformed(evt);
            }
        });
        jMenu4.add(prescription);

        healthChechup.setText("Health Chechup");
        healthChechup.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                healthChechupActionPerformed(evt);
            }
        });
        jMenu4.add(healthChechup);

        viewCaseHistory.setText("View Case History");
        viewCaseHistory.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewCaseHistoryActionPerformed(evt);
            }
        });
        jMenu4.add(viewCaseHistory);

        chageTreatment.setText("Change Treatment");
        chageTreatment.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chageTreatmentActionPerformed(evt);
            }
        });
        jMenu4.add(chageTreatment);

        jMenuBar1.add(jMenu4);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1329, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 2472, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void LogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LogoutActionPerformed
        // TODO add your handling code here:
        Login l = new Login();
        l.setVisible(true);
        this.dispose();

        // tbpanel.removeAll();;


    }//GEN-LAST:event_LogoutActionPerformed

    private void PasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PasswordActionPerformed
        // TODO add your handling code here:
        ChangePassword ch = new ChangePassword();
        ch.setVisible(true);
        desktop.add(ch);
    }//GEN-LAST:event_PasswordActionPerformed

    private void ExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExitActionPerformed
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_ExitActionPerformed

    private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenu2ActionPerformed

    private void PatientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PatientActionPerformed
        // TODO add your handling code here:
        EditPatients p = new EditPatients();
        p.setVisible(true);
        desktop.add(p);
    }//GEN-LAST:event_PatientActionPerformed

    private void DoctorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DoctorActionPerformed
        // TODO add your handling code here:
        EditDoctor ed = new EditDoctor();
        ed.setVisible(true);
        desktop.add(ed);
    }//GEN-LAST:event_DoctorActionPerformed

    private void MedicineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MedicineActionPerformed
        // TODO add your handling code here:
        Medicine me = new Medicine();
        me.setVisible(true);
        desktop.add(me);
    }//GEN-LAST:event_MedicineActionPerformed

    private void RoomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RoomActionPerformed
        // TODO add your handling code here:
        BedRoom br = new BedRoom();
        br.setVisible(true);
        desktop.add(br);
    }//GEN-LAST:event_RoomActionPerformed

    private void FactualyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FactualyActionPerformed
        // TODO add your handling code here:
        Factualy fac = new Factualy();
        fac.setVisible(true);
        desktop.add(fac);
    }//GEN-LAST:event_FactualyActionPerformed

    private void patientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_patientActionPerformed
        // TODO add your handling code here:
        ViewPatients searchPatient = new ViewPatients();
        searchPatient.setVisible(true);
        desktop.add(searchPatient);
    }//GEN-LAST:event_patientActionPerformed

    private void doctorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_doctorActionPerformed
        // TODO add your handling code here:
        ViewDoctor searchDoctor = new ViewDoctor();
        searchDoctor.setVisible(true);
        desktop.add(searchDoctor);
    }//GEN-LAST:event_doctorActionPerformed

    private void addmissionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addmissionActionPerformed
        // TODO add your handling code here:
        AdmissionPatients admission = new AdmissionPatients();
        admission.setVisible(true);
        desktop.add(admission);
    }//GEN-LAST:event_addmissionActionPerformed

    private void dischageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dischageActionPerformed
        // TODO add your handling code here:
        DischargePatient discharge = new DischargePatient();
        discharge.setVisible(true);
        desktop.add(discharge);
    }//GEN-LAST:event_dischageActionPerformed

    private void prescriptionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prescriptionActionPerformed
        // TODO add your handling code here:
        NewPrescription p = new NewPrescription();
        p.setVisible(true);
        desktop.add(p);
    }//GEN-LAST:event_prescriptionActionPerformed

    private void healthChechupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_healthChechupActionPerformed
        // TODO add your handling code here:
        NewHealthCheckup h = new NewHealthCheckup();
        h.setVisible(true);
        desktop.add(h);
    }//GEN-LAST:event_healthChechupActionPerformed

    private void chageTreatmentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chageTreatmentActionPerformed
        // TODO add your handling code here:
        ChangeTreatment ct = new ChangeTreatment();
        ct.setVisible(true);
        desktop.add(ct);
    }//GEN-LAST:event_chageTreatmentActionPerformed

    private void viewCaseHistoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewCaseHistoryActionPerformed
        // TODO add your handling code here:
        ViewCase v = new ViewCase();
        v.setVisible(true);
        desktop.add(v);
    }//GEN-LAST:event_viewCaseHistoryActionPerformed

    private void JSystemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JSystemActionPerformed
        // TODO add your handling code here:
//       for (int i = 0; i < tbpanel.getTabCount(); i++) {
//
//        if (tbpanel.getTitleAt(i).equals("User Manager")) {
//            tbpanel.setSelectedIndex(tbpanel.indexOfTab("User Manager"));
//            return;
//        }
//    }
//    UserManagement um = new UserManagement();
//    int tabCount = tbpanel.getTabCount();
//    tbpanel.add("User Manager", um);
//    tbpanel.setTabComponentAt(tabCount, new CloseableTabComponent(tbpanel, "User Manager"));
//    tbpanel.setSelectedIndex(tbpanel.indexOfTab("User Manager"));
//
    }//GEN-LAST:event_JSystemActionPerformed
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                try {
                    new MainFrame().setVisible(true);
                } catch (UnsupportedLookAndFeelException ex) {
                    Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem Doctor;
    private javax.swing.JMenuItem Exit;
    private javax.swing.JMenuItem Factualy;
    private javax.swing.JMenu JSystem;
    private javax.swing.JMenuItem Logout;
    private javax.swing.JMenuItem Medicine;
    private javax.swing.JMenuItem Password;
    private javax.swing.JMenuItem Patient;
    private javax.swing.JMenuItem Room;
    private javax.swing.JMenuItem addmission;
    private javax.swing.JMenuItem chageTreatment;
    private javax.swing.JMenuItem dischage;
    private javax.swing.JMenuItem doctor;
    private javax.swing.JMenuItem healthChechup;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JMenuItem patient;
    private javax.swing.JMenuItem prescription;
    private javax.swing.JMenuItem viewCaseHistory;
    // End of variables declaration//GEN-END:variables
    private static Connection con;
}
